<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script>

        function sum() {
            let str = $("#arr").val();
            let ss = str.split(",");
            let num = 0
            for (let i = 0; i < ss.length; i++) {
                num+=parseInt(ss[i])
            }

            alert(str+"的和是："+num)
        }

    </script>
</head>
<body>
字符串数组格式：（1,2,3）：<input type="text" id="arr"/>
<input type="button" value="求和" onclick="sum()"/>
</body>
</html>